package com.example.tongzhidemo;

import android.app.Application;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.media.AudioAttributes;
import android.net.Uri;
import android.os.Build;

/**
 * @功能:
 * @Creat 2020/3/26 16:49
 * @User Lmy
 * @Compony JinAnChang
 */
public class app extends Application {


    public static NotificationManager  notificationChannelManager;



    public app() {
        super();
    }

    @Override
    public void onCreate() {
        super.onCreate();
        notificationChannelManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            AudioAttributes att = new AudioAttributes.Builder()
                    .setUsage(AudioAttributes.USAGE_NOTIFICATION)
                    .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
                    .build();
            Uri huifang = Uri.parse("android.resource://" + this.getPackageName() + "/" + R.raw.huifang);
            Uri new_client = Uri.parse("android.resource://" + this.getPackageName() + "/" + R.raw.new_client);
            Uri new_dynamic = Uri.parse("android.resource://" + this.getPackageName() + "/" + R.raw.new_dynamic);
            Uri new_task = Uri.parse("android.resource://" + this.getPackageName() + "/" + R.raw.new_task);
            NotificationChannel huifangcannel = new NotificationChannel("huifang", "回访提示音", NotificationManager.IMPORTANCE_HIGH);
            NotificationChannel new_clientcannel = new NotificationChannel("new_client", "新客户提示音", NotificationManager.IMPORTANCE_HIGH);
            NotificationChannel new_dynamiccannel = new NotificationChannel("new_dynamic", "新动态提示音", NotificationManager.IMPORTANCE_HIGH);
            NotificationChannel new_taskcannel = new NotificationChannel("new_task", "新任务提示音", NotificationManager.IMPORTANCE_HIGH);
            huifangcannel.setSound(huifang, att);
            new_clientcannel.setSound(new_client, att);
            new_dynamiccannel.setSound(new_dynamic, att);
            new_taskcannel.setSound(new_task, att);
            notificationChannelManager.createNotificationChannel(huifangcannel);
            notificationChannelManager.createNotificationChannel(new_clientcannel);
            notificationChannelManager.createNotificationChannel(new_dynamiccannel);
            notificationChannelManager.createNotificationChannel(new_taskcannel);
        }
    }
}
